package com.cq.controller;

import com.cq.pojo.TbDistributor;
import com.cq.service.DissService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/diss")
public class DissController {

    @Autowired
    private DissService dissService;

    @GetMapping("/findDissByUid")
    public List<TbDistributor> findDissByUid(@RequestParam Integer uid) {
        if (uid == 2) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } else if (uid == 1) {
            throw new RuntimeException("异常，熔断");
        }
        return dissService.findDissByUid(uid);
    }
}
